#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

int glob = 6;

int main(int argc, char const* argv[])
{
    int     var;
    pid_t   pid;

    var = 88;
    printf("before vfork\n");
    if ((pid = vfork()) < 0)
    {
        perror("vfork error");
        exit(0); 
        
    }
    else if (pid == 0)
    {
        glob ++;
        var ++;
        //fclose(stdout);
        _exit(0);  //exit(0) has the same result 
    }
    func();

    printf("pid = %d, glob = %d, var = %d\n", getpid(), glob, var);

    return 0;
}
